package com.weiweiqin.dao.impl;

import com.weiweiqin.dao.GamelogDao;
import com.weiweiqin.model.Gamelog;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository
public class GamelogDaoImpl extends GenericMybatisDao<Gamelog, Integer>
		implements GamelogDao {

	public int getLastWinId(int goodsId) {
		Object obj = getSqlSession().selectOne("Gamelog_getLastWinId",goodsId);
		if(null == obj) {
			return 0;
		} else {
			return (Integer)obj;
		}
	}

	public int getAllNumByGoodsId(int goodsId) {
		return (Integer)getSqlSession().selectOne("Gamelog_getAllNumByGoodsId",goodsId);
	}

	public int getFailNum(int id,int goodsId) {
		Map<String,Object> condition = new HashMap<String,Object>();
		condition.put("id", id);
		condition.put("goodsId", goodsId);
		return (Integer)getSqlSession().selectOne("Gamelog_getFailNum",condition);
	}

}